<template>
  <div id="userrecommend">
    
    <h1>发现</h1>
    <el-carousel style="width:90%;margin:0 1rem 0 4rem" :interval="4000" type="card" height="200px">
    <el-carousel-item v-for="item in banner" :key="item">
      <!-- <h3 class="medium"><img src="" alt=""></h3> -->
      <img style="width:100%" :src="item.imageUrl" alt="">
    </el-carousel-item>
  </el-carousel>

     <h2>推荐</h2>
    <div class="greet1"><span>Hi</span><span class="greet2">YuRen</span><span>今日为你推荐</span></div>
    <div class="fabboxxx">
      
      <div class="recommend rituitext" >
        <div class="recommendpicurl" ><span class="ritui">{{redate[0]}}</span></div>
        <div class="recommendname"><span class="data_day">星期{{redate[1]}}</span></div>
      </div>

      <div class="recommend" v-for="item in $store.state.profile.recommend.recommend" :key="item.id">
        <div class="recommendpicurl" @click="toplaylistid(item.id)"><img :src="item.picUrl" alt=""></div>
        <div class="recommendname" @click="toplaylistid(item.id)"><span>{{item.name}}</span></div>
      </div>
    </div>
  </div>
</template>

<script>
import {getbanner} from '../../../network/songlist'

export default {
  name: 'UserRecommend',
  data() {
    return {
      //recommend: null,
      banner:null,
      redate:[], //推荐歌单的日期
    }
  },
  methods: {
    //get歌单ID
    toplaylistid(id) {
      this.$router.push({
        path: '/playlist',
        query: {
          id
        }
      })
    },
    getdata() {
      const a = new Date();
      this.redate.push(a.getDate())
      this.redate.push(a.getDay())
      console.log(this.redate);
    }
  },
  created() {
    //推荐歌单日期
    this.getdata()


    //推荐歌单(登录)
    this.$store.dispatch("getrecommend")

    
    
    //请求轮播图
    getbanner().then(res => {
      this.banner = res.data.banners;
    })
    

  },
}
</script>

<style>
#userrecommend {
  height: 60vh;
  overflow: auto;
}
.greet1 {
  display: inline-block;
  margin: 0 0 0 1rem;
}
.greet2 {
  display: inline-block;
  margin: 0 0.5rem;
}

.fabboxxx {
  width: 100%;
  height: 56vh;
  margin: 1.2rem 1rem 0;
  display: flex;
  flex-wrap: wrap;
  overflow: auto;

}
.recommend {
  width: 9.5vw;
  height: 22vh;
  margin: 0 1.4rem 0 0;


}
.recommendpicurl img{
  width: 9vw;
  height: 17vh;
  border-radius: 15px;
}
.recommendname {
  width: 9vw;
  height: 4vh;
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.9rem;
}
.recommendname span:hover, .recommendpicurl:hover {
  cursor: pointer;
}
.rituitext {
  text-align: center;
}
.ritui {
  font-size:  7rem;
}
.data_day {
  font-size: 2rem;
}


 .el-carousel__item h3 {
    color: #475669;
    font-size: 14px;
    opacity: 0.75;
    line-height: 200px;
    margin: 0;
  }
  
  .el-carousel__item:nth-child(2n) {
    background-color: #99a9bf;
  }
  
  .el-carousel__item:nth-child(2n+1) {
    background-color: #d3dce6;
  }
</style>